home *** CD-ROM | disk | FTP | other *** search
/ Gigarom 1 / Gigarom Macintosh Archives (Quantum Leap)(CDRM1080320)(1993).iso / FILES / DEV / I-Z / Xlisp_Source.cpt / Glue10.LSP < prev    next >
Lisp/Scheme  |  1985-12-04  |  5KB  |  252 lines

  1. ;            GLUE.LSP 1.0
  2. ;            
  3. ;    "Glue" functions for the toolbox call supported by XLISP 1.5b.
  4.  
  5. ;
  6. ;   This is a rough and very incomplete description of the toolbox
  7. ;   facilities available.  Please send corrections and suggestions
  8. ;   to me by easyplex on CIS (George Acton 73026,2663), or to David
  9. ;   Betz at his board (603-623-1711).
  10. ;
  11.  
  12. ;   THE 1.5b GRAPHICS WINDOW
  13. ;
  14. ;   The current version of XLISP has a number of toolbox calls 
  15. ;   implemented in a separate graphics window.  The global 
  16. ;   *graphics-window* holds a pointer to that window for the
  17. ;   toolbox calls.  When one of the built-in graphics functions is
  18. ;   executed, the graphics output is sent to that window and the
  19. ;   current window is reset to the *command-window* on exit.
  20. ;   
  21.     
  22. ;
  23. ;      XLISP GLUE
  24. ;
  25.  
  26. ;
  27. ;   ClearScreen -- defines screen as rectangle, then erases
  28. ;
  29. (defun ClearScreen (&aux screen)
  30.        (setq screen (NewPtr 8))
  31.        (SetRect screen 0 0 512 342)
  32.        (EraseRect screen) ) 
  33.  
  34. ;
  35. ;   simple event manager -- responds to mouse and keyboard
  36. ;
  37. (defun event-man ()
  38.        (prog (result *mou*)
  39.              (setq *mou* (NewPtr 4))
  40.              loop
  41.          (setq result (event-loop *mou*))
  42.          (print result)
  43.          (go loop)) )
  44.  
  45. (defun event-loop (*mou*)
  46.        (prog (ch)
  47.              loop
  48.              (cond ((= (Button) 256)
  49.                (GetMouse *mou*)
  50.                (return (list 'mouse 
  51.                           (peek *mou*) 
  52.                           (peek (+ 2 *mou*)) )) )
  53.          ((setq ch (read-char-no-hang))
  54.              (return (list 'key ch)) )
  55.          (t (go loop)) ) )  )
  56.        
  57. ;
  58. ;       TOOLBOX GLUE  -- keyed to Chernicoff
  59. ;
  60.  
  61. ;
  62. ;   2.2.1 Single Bit Access   
  63. ;
  64. (defun BitTst (ptr offset) 
  65.        (toolbox-16 #xA85D (LoWord ptr) (HiWord ptr)
  66.                           (LoWord offset) (HiWord offset) ) )
  67.  
  68. ;
  69. ;
  70. ;   Word Access -- duplicates HiWord and LoWord 2.2.3
  71. ;
  72. ;    NB HiWord and LoWord are implemented as primitives in XLISP 1.5b.
  73. ;
  74. (defun HiBytes (x)
  75.        (/ x 65536))
  76.        
  77. (defun LoWord (x)
  78.        (rem x 65536))
  79.  
  80. ;
  81. ;   4.1.1 Points
  82. ;
  83. (defun SetPt (pt hc vc)
  84.        (toolbox #xA880 (LoWord pt) (HiWord pt) hc vc) )
  85.        
  86. ;
  87. ;   4.1.2 Rectangles
  88. ;
  89. (defun SetRect (rect left top right bottom)
  90.        (toolbox #xA8A7 (LoWord rect) (HiWord rect) left top right bottom)) 
  91.        
  92. ;
  93. ;   4.1.5 Regions
  94. ;
  95. (defun NewRgn ()
  96.        (toolbox-32 #xA8D8) )
  97.        
  98. (defun DisposeRgn (rgn)
  99.        (toolbox #xA8D9 (LoWord rgn) (HiWord rgn)) )
  100.  
  101. (defun OpenRgn (rgn)
  102.        (toolbox #xA8DA (LoWord rgn) (HiWord rgn)) )
  103.  
  104. (defun CloseRgn (rgn)
  105.        (toolbox #xA8DB (LoWord rgn) (HiWord rgn)) )
  106.  
  107. ;
  108. ;   5.2.2 Setting Pen Characteristics
  109. ;
  110. (defun PenSize (h w)
  111.        (toolbox #xA89B h w) )
  112.  
  113. (defun PenPat (pat)
  114.        (toolbox #xA89D pat) )
  115.        
  116. (defun PenMode (mode)
  117.        (toolbox #xA89C mode) )
  118.  
  119. (defun PenNormal ()
  120.        (toolbox #xA89E) )
  121.        
  122. ;
  123. ;   5.2.3 Hiding and Showing the Pen
  124. ;
  125. (defun HidePen ()
  126.        (toolbox #xA896) )       
  127.  
  128. (defun ShowPen ()
  129.        (toolbox #xA897) )
  130.        
  131. ;
  132. ;   5.2.4 Drawing Lines
  133. ;
  134. (defun GetPen (pt)
  135.        (toolbox #xA89A (LoWord pt) (HiWord pt)) )
  136.        
  137. (defun Move (x y)
  138.        (toolbox #xA894 x y))
  139.  
  140. (defun MoveTo (x y)
  141.        (toolbox #xA893 x y))
  142.  
  143. (defun Line (x y)
  144.        (toolbox #xA892 x y))
  145.  
  146. (defun LineTo (x y)
  147.        (toolbox #xA891 x y))
  148.  
  149. ;
  150. ;   5.3.2 Drawing Rectangles
  151. ;
  152. (defun FrameRect (rect)
  153.        (toolbox #xA8A1 (LoWord rect) (HiWord rect)) )
  154.  
  155. (defun PaintRect (rect)
  156.        (toolbox #xA8A2 (LoWord rect) (HiWord rect)) )
  157.  
  158. (defun EraseRect (rect)
  159.        (toolbox #xA8A3 (LoWord rect) (HiWord rect)) )
  160.  
  161. (defun InvertRect (rect)
  162.        (toolbox #xA8A4 (LoWord rect) (HiWord rect)) )
  163.  
  164. ;
  165. ;   5.3.4 Drawing Ovals
  166. ;
  167. (defun FrameOval (rect)
  168.        (toolbox #xA8B7 (LoWord rect) (HiWord rect)) )
  169.  
  170. (defun PaintOval (rect)
  171.        (toolbox #xA8B8 (LoWord rect) (HiWord rect)) )
  172.  
  173. (defun EraseOval (rect)
  174.        (toolbox #xA8B9 (LoWord rect) (HiWord rect)) )
  175.  
  176. (defun InvertOval (rect)
  177.        (toolbox #xA8BA (LoWord rect) (HiWord rect)) )
  178.  
  179.  
  180. ;
  181. ;   5.3.7 Drawing Regions
  182. ;
  183. (defun FrameRgn (rgn)
  184.        (toolbox #xA8D2 (LoWord rgn) (HiWord rgn)) )
  185.        
  186. (defun EraseRgn (rgn)
  187.        (toolbox #xA8D4 (LoWord rgn) (HiWord rgn)) )
  188.  
  189. ;
  190. ;   8.3.2 Setting Text Characteristics
  191. ;
  192. (defun TextFont (x)
  193.        (toolbox #xA887 x))
  194.       
  195. (defun TextSize (x)
  196.        (toolbox #xA88A x))
  197.        
  198. (defun TextFace (x)
  199.        (toolbox #xA888 x))
  200.         
  201. (defun TextMode (x)
  202.        (toolbox #xA889 x))
  203.        
  204. ;
  205. ;   8.3.3 Drawing Text
  206. ;
  207. (defun DrawChar (x)
  208.        (toolbox #xA883 x))
  209.  
  210. ;
  211. ;   Chernikoff -- vol. 2
  212. ;
  213.  
  214. ;
  215. ;   Event Management
  216. ;
  217. ;   The XLISP event loop uses the toolbox call GetNextEvent, which clears
  218. ;   the event queue.  It is possible to read the mouse and keyboard
  219. ;   buffers directly.  Also, the XLISP function (get-char-no-hang) can be
  220. ;   used to examine the keyboard.
  221. ;
  222.  
  223. ;
  224. ;   2.4.1 Reading the Mouse Position
  225. ;
  226. (defun GetMouse (pt)
  227.        (toolbox #xA972 (LoWord pt) (HiWord pt)) )
  228.        
  229. ;
  230. ;   2.4.2 Reading the Mouse Button
  231. ;
  232. (defun Button ()
  233.        (toolbox-16 #xA974) )
  234.  
  235. ;
  236. ;   1.6.1 Reading the Keyboard
  237. ;
  238. ;    keymap: 16 bytes
  239. ;    global: $174
  240. ;
  241. (defun GetKeys (keymap)
  242.        (toolbox #xA976 (LoWord keymap) (HiWord keymap)) )
  243. ;
  244. ;   2.8.1 Beeping the Speaker
  245. ;
  246. ;    NB mistake in Chernikoff.  Arg is ticks, not secs.
  247. ;
  248. (defun Sysbeep (n)
  249.        (toolbox #xA9C8 n))
  250.  
  251.  
  252.